<?php
namespace app\index\controller;

use tool\Common;

class Index
{
    public $app = [];
    public $token = '';
    public $path = '';

    public function index()
    {
        $url = "http://localhost/menhai/public/minapp/".$this->path;
        //$url = "http://louyu.qianchengwl.cn/minapp/".$this->path;
        $post_data = [
            'token' => $this->token,
            'timestamp' => '2017-06-15 22:22:22',
            'app' => $this->app
        ];
        $checksum = $post_data['token'].$post_data['timestamp'].json_encode($post_data['app'],JSON_UNESCAPED_SLASHES |JSON_UNESCAPED_UNICODE);
        $post_data['checksum'] = md5($checksum);
        //echo json_encode($post_data);exit;
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        // post数据
        curl_setopt($ch, CURLOPT_POST, 1);
        // post的变量
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post_data));
        $output = curl_exec($ch);
        curl_close($ch);
        //打印获得的数据
        print_r($output);
    }

    public function login()
    {
        $this->app = [
            'mobile' => '15972919764',
            'password' => '123456'
        ];
        $this->path = 'user/login';
        $this->token = '';
        $this->index();
    }

    public function getPatrolList()
    {
        $this->app = [
            'beginDate' => '2017-10-1',
            'endDate' => '2017-10-17',
            'typeID' => 2
        ];
        $this->path = 'patrol/getPatrolList';
        $this->token = 'c87961fe528dd19533a7112904fab880';
        $this->index();
    }

    public function createReport()
    {
        $this->app = [
            'typeID' => 2
        ];
        $this->path = 'report/createReport';
        $this->token = 'd9abd3060ea18a6061149885bbd2e8f9';
        $this->index();
    }

    public function getOnePatrolList()
    {
        $this->app = [
            'patrolIcon' => '1504232045',
            'typeID' => 3,
            'groupID' => 1
        ];
        $this->path = 'patrol/getOnePatrolList';
        $this->token = '24e5e9ab7fcb0e19123964c616a2cb36';
        $this->index();
    }

    public function dealWarn()
    {
        $this->app = [
            'warnID' => 207,
            'photoList' => [
                'http://zheshang.patrol.qianchengwl.cn/uploads/20170728/a552c41f9b6f38a25a065008a36ec186.jpg',
                'http://zheshang.patrol.qianchengwl.cn/uploads/20170728/6def235c5ede020d295cc840100ca1ba.jpg'
            ],
            'voice' => 'http://zheshang.patrol.qianchengwl.cn/uploads/20170728/11e25882bbef2c03689f27faf5e6086e.mp3'
        ];
        $this->path = 'warn/dealWarn';
        $this->token = '25616a10d9069e2522fd13d8cd473a9b';
        $this->index();
    }

    public function getGroupList()
    {
        $this->app = [
            'status' => 1,
            'typeID' => 2,
            'patrolIcon' => 1506394128
        ];
        $this->path = 'patrol/getGroupList';
        $this->token = 'dcf014740a18639ef6d899afc06e907c';
        $this->index();
    }

    public function createOnePatrol()
    {
        $this->app = [
            'RFIDNum' => 'E000490F'
        ];
        $this->path = 'patrol/createOnePatrol';
        $this->token = 'c87961fe528dd19533a7112904fab880';
        $this->index();
    }

    public function getOnePatrolPlaceContent()
    {
        $this->app = [
            'patrolID' => 23715
        ];
        $this->path = 'patrol/getOnePatrolPlaceContent';
        $this->token = '0295ca806b27aa68d99b3472a9127899';
        $this->index();
    }

    public function getReportDetail()
    {
        $this->app = [
            'reportID' => 430
        ];
        $this->path = 'report/getReportDetail';
        $this->token = '004fa9e8d4e9429ec3992272560f82e2';
        $this->index();
    }

    public function getWarnDetail()
    {
        $this->app = [
            'warnID' => 330
        ];
        $this->path = 'warn/getWarnDetail';
        $this->token = 'dcf014740a18639ef6d899afc06e907c';
        $this->index();
    }

    public function getIndex()
    {
        $this->app = [
            'typeID' => 1,
            'page' => [
                'index' => 1,
                'count' => 10
            ]
        ];
        $this->path = 'index/getIndex';
        $this->token = '657d8f5499f29a53418cc6cb70ab195f';
        $this->index();
    }

    public function getUserWarn()
    {
        $this->app = [

        ];
        $this->path = 'user/getUserWarn';
        $this->token = 'f9fa2e40882c2f5966b04ed718b94213';
        $this->index();
    }
}
